﻿using System.Linq;
using Abp.Authorization;
using Abp.Localization;
using LeadThing.AbpZeroTemplate.Authorization;



namespace LeadThing.AbpZeroTemplate.FireFightingWorks.Authorization
{
    /// <summary>
    /// 权限配置都在这里。
    /// 给权限默认设置服务
    /// See <see cref="FireFightingWorkAppPermissions"/> for all permission names.
    /// </summary>
    public class FireFightingWorkAppAuthorizationProvider : AuthorizationProvider
    {
        public override void SetPermissions(IPermissionDefinitionContext context)
        {
            //在这里配置了FireFightingWork 的权限。

            var pages = context.GetPermissionOrNull(AppPermissions.Pages) ?? context.CreatePermission(AppPermissions.Pages, L("Pages"));

            var entityNameModel = pages.Children.FirstOrDefault(p => p.Name == AppPermissions.Pages_FireFightingWorkManage)
              ?? pages.CreateChildPermission(AppPermissions.Pages_FireFightingWorkManage, L("Pages_FireFightingWorkManage"));





            var fireFightingWork = entityNameModel.CreateChildPermission(FireFightingWorkAppPermissions.FireFightingWork, L("FireFightingWork"));
            //fireFightingWork.CreateChildPermission(FireFightingWorkAppPermissions.FireFightingWork_CreateFireFightingWork, L("CreateFireFightingWork"));
            //fireFightingWork.CreateChildPermission(FireFightingWorkAppPermissions.FireFightingWork_EditFireFightingWork, L("EditFireFightingWork"));
            //fireFightingWork.CreateChildPermission(FireFightingWorkAppPermissions.FireFightingWork_DeleteFireFightingWork, L("DeleteFireFightingWork"));
            fireFightingWork.CreateChildPermission(FireFightingWorkAppPermissions.FireFightingWork_DetailFireFightingWork, L("DetailFireFightingWork"));

        }

        private static ILocalizableString L(string name)
        {
            return new LocalizableString(name, AbpZeroTemplateConsts.LocalizationSourceName);
        }
    }
}